// ********************************************************************************************
// Este archivo fuente es propiedad de Feria de Remates S.R.L. de C.V. Prohibida su copia o uso
// sin autorización explícita.
// This source file is propietary to Feria de Remates S.R.L. de C.V. May not be used or copied
// without explicit authorization.
// ********************************************************************************************/
package com.feriaderemates.dao.user;

import com.feriaderemates.domain.userAccount.User;
import java.sql.Timestamp;

/**
 * Interface for dao classes to implements user transactions
 *
 * @author Oscar Garcia
 */
public interface UserDaoInterface {

    /**
     * Registers User fields.
     *
     * @param user the user to register.
     * @param registrationConfirmationCode code use to verify user's email after registration
     * @return the unique User id returned after the insert.
     */
    public int registerUser(User user, String registrationConfirmationCode);

    /**
     * Gets a user by his username. See the User.createUserFromDb method
     * to know what fields are needed
     *
     * @param username the username
     * @return the User instance
     */
    public User getUserByUsername(String username);

    /**
     * Gets a user by his email. See the User.createUserFromDb method
     * to know what fields are needed
     *
     * @param email the user's email
     * @return the User instance
     */
    public User getUserByEmail(String email);

    /**
     * Updates basic user's information. Updates all the fields except
     * the password and the id.
     *
     * @param user the user to update
     */
    public void updateUser(User user);

    /**
     * Updates user's password and sets the field last_recovery_code_request to NOW()
     *
     * @param newPassword the new password
     * @param recoveryCode the recoveryCode to find the account
     */
    public void updateUserPassword(String newPassword, String recoveryCode);
    
    
    /**
     * Gets the last time when the user requested to reset his password.
     * 
     * @param email user's email
     * @return the timestamp
     */
    public Timestamp getLastTimeUserRequestedResetPassword(String email);

    /**
     * Set's a code to the recovery code column in the user table.
     * 
     * @param email the user's email
     * @param recoveryCode the code to set
     */
    public void setUsersRecoveryCode(String email, String recoveryCode);
}
